/*
 * Project: Set Sample
 * Copyright (C) 2013 alf.labs gmail com,
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.alflabs.setsample.presenter;

import com.alflabs.annotations.NonNull;
import com.alflabs.setsample.stats.SetResult;

import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;


public class MockAbstractView implements IAbstractView {
    private final Map<String, Integer> mCalls = new TreeMap<String, Integer>();

    @Override
    public void resetBoard() {
        _inc("resetBoard");
    }

    @Override
    public void resetSolutions() {
        _inc("resetSolutions");
    }

    @Override
    public void onNewUserSolution(int msg) {
        _inc("onNewUserSolution[" + msg + "]");
    }

    @Override
    public void onBoardCompleted(SetResult setResult) {
        _inc("onBoardCompleted[" + setResult + "]");
    }

    @Override
    public void deselectCells(@NonNull int... indexes) {
        _inc("deselectCell" + Arrays.toString(indexes));
    }

    @Override
    public String toString() {
        return mCalls.toString();
    }

    public void clearCalls() {
        mCalls.clear();
    }

    private void _inc(@NonNull String key) {
        Integer i = mCalls.get(key);
        mCalls.put(key, 1 + (i == null ? 0 : i));
    }
}
